import { useIntersectionObserver } from '@vueuse/core'
import { ref } from 'vue'
export function userHook (apiFn) {
  const target = ref(null)
  const { stop } = useIntersectionObserver(
    target,
    ([{ isIntersecting }]) => {
      console.log('进入到可视区域', isIntersecting)
      if (isIntersecting) {
        // 进入可是区域内发请求
        apiFn()
        // 进入到可视区域内，停止
        stop()
      }
    },

    { threshold: 0 }
  )
  return { target }
}
